<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Validator;
use Laravel\Lumen\Routing\Controller as BaseController;
use App\Libraries\Send;
use App\Libraries\Tools;

class Controller extends BaseController
{
    use Send, Tools;


    /**
     * Notes:清除Redis所有缓存
     */
    public static function redisFlushAll()
    {

        $ip    = env('REDIS_HOST');
        $port  = env('REDIS_PORT');
        $redis = new \Redis();
        $redis->pconnect($ip, $port, 1);
        $redis->flushAll();
    }

    /**
     * 數據驗證
     */
    public function checkValidate($rules, $params, $field = [], $message = [])
    {
        $v = Validator::make($params, $rules, $message, $field);
        if ($v->fails())
            self::dieError($v->errors()->first());
        return $params;
    }
}
